package com.rimi.project.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.rimi.project.dao.BookDao;
import com.rimi.project.dao.impl.BookDaoImpl;

@WebServlet("/book/batchdelete")
public class BookBatchDeleteServlet extends HttpServlet{
	

	private BookDao bookDao = new BookDaoImpl();
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// 获取被删除的id列表
		String ids = req.getParameter("idlist");
		
		String[] idArray = ids.split(",");
		System.out.println(ids);
		System.out.println(idArray.length);

		boolean isOk = bookDao.deleteBookByIds(idArray);
		
		resp.getWriter().print(isOk);
	}
}
